<?php
namespace WebApper\Shortcode;

/*
 * [paymentreporting]
 *
 */
 class PaymentReporting extends \WebApper\Shortcode {
	
    /**
     * Define shortcode properties
     *
     */
	protected $shortcode = 'payment_reporting';

    /**
     * Initialize the Shortcode Class
     *
     */
    public function __construct() {
		add_shortcode( $this->shortcode, array($this, 'shortcode') );
		add_action( 'wp_ajax_web_apper' . $this->shortcode, array($this, 'sendAjaxResponse') );
		add_action( 'wp_ajax_nopriv_web_apper' . $this->shortcode, array($this, 'sendAjaxResponse') );	   	
	}

    /**
     * Handles the add post shortcode
     *
     * @param array $atts
     */
	 
    public function shortcode( $atts ) {

		global $wpdb, $webapper;
		$post_id = $_GET['postID']; 
		$get_post_meta      = get_post_meta($post_id);
	    $email_address 		= $get_post_meta['email-primary'][0];
	    $exist_user_id = email_exists($email_address);
		// FETCHING DATA FROM USER PAYMENT TRANSACTION  
		$payment_transaction          = web_apper_get_payment_transaction($exist_user_id);
		$user_payment_transaction_id  = $payment_transaction -> user_payment_transaction_id;
		$user_id  					  = $payment_transaction -> user_id;
		$payment_for  				  = $payment_transaction -> payment_for;
		$received_as  				  = $payment_transaction -> received_as;
		$amount_paid  				  = $payment_transaction -> amount_paid;
		$transaction_date  			  = $payment_transaction -> transaction_date;
		$transaction_status  		  = $payment_transaction -> transaction_status;
		$created_on  				  = $payment_transaction -> created_on;
		$edited_on  				  = $payment_transaction -> edited_on;
		?>

<div id="paymentReporting" style="display:none;">
  <h3> Payment Reporting </h3>
  <form class="form-horizontal">
    <div class="control-group">
      <label class="control-label" for="PaymentCleared">Payment Cleared:</label>
      <div class="controls">
        <label class="control-label" for="PaymentCleared"><?php echo count($user_payment_transaction_id) ?></label>
      </div>
    </div>
    <div class="control-group">
      <label class="control-label" for="Payment Remaining">Payment Remaining:</label>
      <div class="controls">
        <label class="control-label" for="Payment Remaining"><?php echo $payments_remaining; ?></label>
      </div>
    </div>
    <div class="control-group">
      <label class="control-label" for="Amount Paid">Amount Paid(Cleared):</label>
      <div class="controls">
        <label class="control-label" for="Amount Paid"><?php echo $amount_paid; ?></label>
      </div>
    </div>
    <div class="control-group">
      <label class="control-label" for="Balance">Balance:</label>
      <div class="controls">
        <label class="control-label" for="Balance"><?php echo $balance; ?></label>
      </div>
    </div>
    <div class="control-group">
      <label class="control-label" for="Default amount">Default amount:</label>
      <div class="controls">
        <label class="control-label" for="Default amount"><?php echo $default_amount; ?></label>
      </div>
    </div>
    <div class="control-group">
      <label class="control-label" for="Date signed Up">Date signed Up:</label>
      <div class="controls">
        <label class="control-label" for="Date signed Up"><?php echo $created_on ; ?></label>
      </div>
    </div>
    <div class="control-group">
      <label class="control-label" for="Membership Expiration">Membership Expiration:</label>
      <div class="controls">
        <label class="control-label" for="Membership Expiration"><?php echo $end_date; ?></label>
      </div>
    </div>
  </form>
</div>
<?php	}		
}
$initialize = new PaymentReporting(); 

?>
